package appapi.config;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;
import javax.servlet.Filter;

@Configuration
public class FilterConfig {
    @Resource
    private ArgumentFilter argumentFilter;

    @Bean
    public FilterRegistrationBean<Filter> registerAuthFilter() {
        FilterRegistrationBean<Filter> registration = new FilterRegistrationBean<>();
        registration.setFilter(argumentFilter);
        registration.addUrlPatterns("/api/test/level2");
        registration.setName("authFilter");
        // 值越小，Filter越靠前
        registration.setOrder(1);
        return registration;
    }
}

